package gameObject;

import java.awt.Point;

import entity.Entity;

public abstract class MovableObject extends Entity 
{
	public abstract void move();
	private boolean _active;
	private int _angle;
	
	public void setAngle(int newAngle)
	{
		_angle = newAngle;
	}
	
	public int getAngle()
	{
		return _angle;
	}
	
	public boolean isActive()
	{
		return _active;
	}
	
	public void setActive(boolean newState)
	{
		_active = newState;
	}
	
	public void activate(Point newPosition, int newAngle)
	{
		super.setPosition(newPosition);
		setActive(true);
		setAngle(newAngle);
	}

	public void deactivate() 
	{
		this.setActive(false);		
	}

	//TODO adjust formula
	public void moveGameObject(int gameObjectVelocity) 
	{
		int newPositionX = updateX(gameObjectVelocity);
		int newPositionY = updateY(gameObjectVelocity);
		Point newPosition = new Point(newPositionX,newPositionY); //change X/Y rather than making new points
		super.setPosition(newPosition);		
	}
	//TODO adjust formula
	private int updateX(int gameObjectVelocity)
	{
		return super.getPosition().x +  (int) ((int) gameObjectVelocity * Math.cos(_angle));
	}
	//TODO adjust formula
	private int updateY(int gameObjectVelocity)
	{
		return super.getPosition().y +  (int) ((int) gameObjectVelocity * Math.sin(_angle));
	}
	

}
